package com.thor.palmmall.rest.order.converter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.rest.order.AOrderActivitie;
import com.thor.palmmall.spi.order.SOrderActivitie;

public class AOrderActivitieConverter
    implements Converter<List<SOrderActivitie>, List<AOrderActivitie>> {
  public static AOrderActivitieConverter getInstance() {
    if (instance == null)
      instance = new AOrderActivitieConverter();
    return instance;
  }

  private static AOrderActivitieConverter instance;

  @Override
  public List<AOrderActivitie> convert(List<SOrderActivitie> sourceList) {
    if (sourceList == null || sourceList.size() == 0) {
      return null;
    }
    List<AOrderActivitie> list = new ArrayList<AOrderActivitie>();
    for (SOrderActivitie source : sourceList) {
      AOrderActivitie target = new AOrderActivitie();
      target.setUuid(source.getUuid());

      target.setActivityName(source.getActivityName());

      target.setPromotionUuid(source.getPromotionUuid());

      target.setVoucherTotal(source.getVoucherTotal());

      list.add(target);
    }
    return list;
  }

}
